package TOP101;

import com.sun.org.apache.xpath.internal.operations.Bool;

/**
 * @Question BM34
 * @Date 2022/11/18 10:04
 * @Solution
 */
public class BM34 {
    Boolean isValid=true;
    int min=Integer.MIN_VALUE;
    public boolean isValidBST (TreeNode root) {
        // write code here
        Travel(root);
        return isValid;
    }
    public void Travel(TreeNode cur) {
        if(cur==null) {
            return;
        }
        Travel(cur.left);
        if(cur.val<=min) {
            isValid=false;
        }
        min=cur.val;
        Travel(cur.right);
    }
}
